package com.hanxiaozhang.state.no1;

/**
 * 〈一句话功能简述〉<br>
 * 〈上下文类〉
 *
 * @author hanxinghua
 * @create 2025/4/17
 * @since 1.0.0
 */
public class TextEditor {

    private State state;

    /**
     * 设置当前状态的方法
     *
     * @param state
     */
    public void setState(State state) {
        this.state = state;
    }

    /**
     * 执行当前状态的行为的方法
     */
    public void doAction() {
        if (state != null) {
            state.doAction();
        } else {
            System.out.println("No state is set.");
        }
    }
}
